package com.sixbro.resource.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *
 * </p>
 *
 * @author: Mr.Lu
 * @since: 2021/11/2 16:30
 */
@RestController
@RequestMapping("/file")
public class FileController {

    @GetMapping
    public ResponseEntity< Void > get() {
        return ResponseEntity.noContent( ).build( );
    }

    @PreAuthorize( "hasRole('adm') or hasPermission(null, 'file:add')" )
    @PostMapping
    public ResponseEntity< Boolean > add() {
        return ResponseEntity.ok(Boolean.TRUE);
    }

    @PreAuthorize( "hasRole('admin') or hasPermission('file:edit')" )
    @PutMapping
    public ResponseEntity< Boolean > edit() {
        return ResponseEntity.ok(Boolean.TRUE);
    }

    @PreAuthorize( "hasRole('admin') or hasPermission('file:delete')" )
    @DeleteMapping
    public ResponseEntity< Boolean > del() {
        MethodSecurityInterceptor methodSecurityInterceptor;
        FilterSecurityInterceptor filterSecurityInterceptor;

        //org.springframework.security.access.expression.method.MethodSecurityExpressionRoot methodSecurityExpressionRoot;
        return ResponseEntity.ok(Boolean.TRUE);
    }
}
